[20260202] BOJ / G4 / 소트 / 이준희 #1872
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
🧷 문제 링크
https://www.acmicpc.net/problem/1083
🧭 풀이 시간
40분
👀 체감 난이도
✏️ 문제 설명
서로 다른 숫자들로 이루어진 수열을 소트하려고 합니다.
이 때 소트는 인접한 두 숫자의 위치를 바꾸는 행위 입니다.
수열을 S번 소트할 때 사전순으로 가장 뒤에 있는 수열을 출력하는 문제입니다.
🔍 풀이 방법
사전 순 가장 뒤에 있는 수열을 출력하기 위해서는
매 순간 가능한한 큰 숫자를 가져와야 합니다.
따라서 0번 idx 부터 s만큼의 범위까지의 숫자 중 가장 큰 숫자를 찾아서 가져왔습니다.
⏳ 회고
그리디는 항상 이게 맞나..? 긴가민가 하게 풀리는데 명확하게 설명을 잘 못하겠습니다.